﻿using Microsoft.EntityFrameworkCore;
using PersonnelStatistics.Entities;

namespace PersonnelStatistics.DAL
{
    //3、创建数据库上下文,继承 DbContext类
    public class MyDbContext : DbContext
    {
        //设置对应的。属性名必须 跟表名一样
        public DbSet<Personal> Table { get; set; }
        public MyDbContext()
        {

        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //获取程序设置的服务器网址和登录名密码。
            string dataSource = "Data Source=" + MyDbContextOptions.DataSource
                         + ";Initial Catalog=" + MyDbContextOptions.DbName
                         + ";User ID=" + MyDbContextOptions.DbAccount+ ";password="
                         + MyDbContextOptions.Password;
            //配置数据库连接
            // optionsBuilder.UseSqlServer("Data Source=www.severa-market.com,10270;Initial Catalog=test;User ID=cl;password=801014");
            optionsBuilder.UseSqlServer(dataSource);
        }

    }
}
